// uno.config.ts
import { defineConfig, presetAttributify, presetUno } from "unocss";

export default defineConfig({
  presets: [
    presetAttributify({
      /* preset options */
    }),
    presetUno(),
  ],
  rules: [
    /** match[1]代表获取到的值 */
    [/^bg-color-([\w]+)$/, ([, color]) => ({ background: `#${color}` })],
    [/^text-color-([\w]+)$/, ([, color]) => ({ color: `#${color}` })],
    [
      /^bg-white-tr-.(\d+)$/,
      (match) => ({ background: `rgba(255,255,255,0.${+match[1]})` }),
    ],

    [/^p-(\d+)$/, (match) => ({ padding: `${+match[1] * 10}px` })],
  ],
  shortcuts: [
    {
      "flex-center": "flex items-center justify-center",
      "overflow-box": "flex-1 overflow-hidden",
    },
  ],
});
